# -*- coding: utf-8 -*-
# @Time    : 2021/3/24 11:37
# @Author  : huangwei
# @File    : method.py
# @Software: PyCharm
import os
import base64
import shutil


def getByte( path ):
    """文件转为unicode编码"""
    with open(path, 'rb') as f:
        img_byte = base64.b64encode(f.read())  # 二进制读取后变base64编码
    img_str = str(img_byte, encoding='utf-8')
    return img_str


def delete_dir( dir_path ):
    """删除文件夹"""
    if os.path.exists(dir_path):
        shutil.rmtree(dir_path)
    else:
        print("%s is not exists")


def create_dir( dir_path ):
    """创建文件夹"""
    if not os.path.exists(dir_path):
        os.makedirs(dir_path)
    else:
        print("%s is exists" % dir_path)
